/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.general.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.general.be.ColegiadoComiteLocal;
import org.cip.esymons.general.be.ComiteLocal;

/**
 *
 * @author ADMINISTRADOR
 */
@Stateless
public class ColegiadoComiteLocalFacade implements ColegiadoComiteLocalFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(ColegiadoComiteLocal colegiadoComiteLocal) {
        em.persist(colegiadoComiteLocal);
    }

    public void edit(ColegiadoComiteLocal colegiadoComiteLocal) {
        em.merge(colegiadoComiteLocal);
    }

    public void remove(ColegiadoComiteLocal colegiadoComiteLocal) {
        em.remove(em.merge(colegiadoComiteLocal));
    }

    public ColegiadoComiteLocal find(Object id) {
        return em.find(ColegiadoComiteLocal.class, id);
    }

    public List<ColegiadoComiteLocal> findAll() {
        return em.createQuery("select object(o) from ColegiadoComiteLocal as o order by o.colCodigo.colnumeroCip").getResultList();
    }

    public List<ColegiadoComiteLocal> listaColegiadosOrdenCIP() {
        return em.createQuery("select object(o) from ColegiadoComiteLocal as o order by o.colCodigo.colnumeroCip").getResultList();
    }

    public List<ColegiadoComiteLocal> listaColegiadosOrdenApellidos() {
        return em.createQuery("select object(o) from ColegiadoComiteLocal as o order by o.colCodigo.personaNatural.perapellidoPaterno").getResultList();
    }

    public List<ColegiadoComiteLocal> listaColegiadosOrdenComite() {
        return em.createQuery("select object(o) from ColegiadoComiteLocal as o order by o.cloCodigo.cloNombre").getResultList();
    }

    public List<ColegiadoComiteLocal> listaColegiadosPorComite(ComiteLocal comite) {
        return em.createQuery("select object(o) from ColegiadoComiteLocal as o where o.cloCodigo=?1 order by o.colCodigo.colnumeroCip").setParameter(1, comite).getResultList();
    }

}
